<HTML><HEAD><TITLE>cancel_after_event(+Event, -CancelledEvents)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Event Handling</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>cancel_after_event(+Event, -CancelledEvents)</H1>
Cancel all pending instances of after event Event
<DL>
<DT><EM>Event</EM></DT>
<DD>Atom or Handle
</DD>
<DT><EM>CancelledEvents</EM></DT>
<DD>Variable
</DD>
</DL>
<H2>Description</H2>
   All instances of the pending after event Event is 
   cancelled so that the event will not be triggered. A pending after event 
   is an event which is setup by either event_after/2, event_after/3 or 
   event_after_every/2, and which is waiting to be raised 
   (event_after_every/2 will always be pending as it is raised repeatedly).
<P>
   CancelledEvents is the list of after events that have been cancelled. 
   Each element of CancelledEvents is of the form of an event specified
   in Events of events_after / 1. As a result, CancelledEvents can be
   reposted using events_after(CancelledEvents). If there was no event
   to cancel, CancelledEvents will be bound to the empty list.
<P>
   Note that the processing of an already raised, but as yet unprocessed
   event will not be cancelled by this predicate (but you can use
   event_disable/1 to achieve this).

<H3>Modes and Determinism</H3><UL>
<LI>cancel_after_event(+, -) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>Event is not an atom.
</DL>
<H2>Examples</H2>
<PRE>
    % setup an after event and cancel immediatedly
    ?- event_create(writeln(hi), [], E),
	event_after(E, 3.2),
	cancel_after_event(E, Cancelled).
    E = 'EVENT'(16'ed980a58)
    Cancelled = ['EVENT'(16'ed980a58) - 3.1999999999999886]
    Yes (0.00s cpu)

    % no after-event requested, nothing to cancel
    ?- event_create(writeln(hi), [], E),
	cancel_after_event(E, Cancelled).
    E = 'EVENT'(16'ed980a58)
    Cancelled = []
    Yes (0.00s cpu)

    % setup an after event and cancel immediatedly
    ?- event_create(writeln(hi), [], E1),
	event_after_every(E1, 1),
	event_create((cancel_after_event(E1, C1), writeln(cancelled(C1))), [], E2),
	event_after(E2, 5),
	repeat, fail.
    hi
    hi
    hi
    hi
    cancelled(['EVENT'(16'edbc0cc0) - every(1)])

</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/event/event_after-2.html">event_after / 2</A>, <A HREF="../../kernel/event/event_after-3.html">event_after / 3</A>, <A HREF="../../kernel/event/event_disable-1.html">event_disable / 1</A>, <A HREF="../../kernel/event/event_after_every-2.html">event_after_every / 2</A>, <A HREF="../../kernel/event/event-1.html">event / 1</A>, <A HREF="../../kernel/event/set_event_handler-2.html">set_event_handler / 2</A>, <A HREF="../../kernel/event/current_after_events-1.html">current_after_events / 1</A>, <A HREF="../../kernel/event/event_create-3.html">event_create / 3</A>, <A HREF="../../kernel/event/event_retrieve-3.html">event_retrieve / 3</A>
</BODY></HTML>
